home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
wsc4c21.zip
/
WSC4C_R.TXT
< prev
next >
Wrap
Text File
|
1997-06-01
|
46KB
|
1,442 lines
Windows Standard Serial Communications
Library for C/C++
(WSC4C)
REFERENCE MANUAL
Version 2.1
June 2, 1997
This software is provided as-is.
There are no warranties, expressed or implied.
Copyright (C) 1996-1997
All rights reserved
MarshallSoft Computing, Inc.
Post Office Box 4543
Huntsville AL 35815
Voice : 205-881-4630
FAX : 205|880|0925
BBS : 205-880-9748
email : info@marshallsoft.com
web : www.marshallsoft.com
_______
____|__ | (R)
--+ | +-------------------
| ____|__ | Association of
| | |_| Shareware
|__| o | Professionals
--+--+ | +---------------------
|___|___| MEMBER
WSC4C Reference Manual Page 1
C O N T E N T S
Chapter Page
Table of Contents.............................2
WSC Functions.................................4
SioBaud....................................4
SioBrkSig..................................4
SioCTS.....................................5
SioDCD.....................................5
SioDone....................................6
SioDSR.....................................6
SioDTR.....................................7
SioFlow....................................7
SioGetc....................................8
SioGets....................................8
SioInfo....................................9
SioParms...................................9
SioPutc...................................10
SioPuts...................................10
SioRead...................................11
SioReset..................................11
SioRI.....................................12
SioRTS....................................12
SioRxClear................................13
SioRxQue..................................13
SioStatus.................................14
SioTxClear................................14
SioTxQue..................................15
SioUnGetc.................................15
WSC Error Codes..............................16
WSC4C Reference Manual Page 2
C O N T E N T S
(continued)
Chapter Page
Modem I/O Functions..........................17
mioBreak..................................17
mioDriver.................................17
mioQuiet..................................18
mioResult.................................18
mioSendTo.................................19
mioWaitFor................................19
XYDRIVER Functions...........................20
xyAbort...................................20
xyAcquire.................................20
xyDebug...................................21
xyDriver..................................21
xyGetMessage..............................22
xyGetParameter............................22
xyRelease.................................23
xyStartRx.................................23
xyStartTx.................................24
XYDRIVER Error Codes.........................24
WSC4C Reference Manual Page 3
+-------------+-----------------------------------------------------+
| SioBaud | Sets the baud rate. |
+-------------+-----------------------------------------------------+
SYNTAX int SioBaud(int Port, int BaudCode)
// Port : Port selected.
// BaudCode : Baud code or actual baud rate.
REMARK The SioBaud function sets the baud rate without resetting
the port. It is used to change the baud rate after calling
SioReset.
SioBaud may be called with either the actual baud rate value
or one of the baud rate codes as follows:
Code Rate Name Code Rate Name
0 300 Baud300 5 9600 Baud9600
1 600 Baud600 6 19200 Baud19200
2 1200 Baud1200 7 38400 Baud38400
3 2400 Baud2400 8 57600 Baud57600
4 4800 Baud4800 9 115200 Baud115200
For example, to set 28800, SioBaud(Port,28800);
RETURN IE_BADID : No such port.
IE_BAUDRATE : Unsupported baud rate.
OTHER See SioReset.
+-------------+-----------------------------------------------------+
| SioBrkSig | Asserts, cancels, or detects BREAK signal. |
+-------------+-----------------------------------------------------+
SYNTAX int SioBrkSig(int Port, int Cmd)
// Port : Port selected.
// Cmd : ASSERT, CANCEL, or DETECT
REMARK The SioBrkSig function controls the BREAK bit in the line
status register. The legal commands are:
ASSERT_BREAK : 'A' to assert BREAK
CANCEL_BREAK : 'C' to cancel BREAK
DETECT_BREAK : 'D' to detect BREAK
ASSERT_BREAK, CANCEL_BREAK, and DETECT_BREAK are defined in
WSC.H. See MODEM.C for an example of the use of SioBrkSig.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
WSC_RANGE : Illegal command. Expected 'A', 'C', or 'D'.
>0 : BREAK signal detected (DETECT command only)
WSC4C Reference Manual Page 4
+-------------+-----------------------------------------------------+
| SioCTS | Reads the Clear to Send (CTS) modem status bit. |
+-------------+-----------------------------------------------------+
SYNTAX int SioCTS(int Port)
// Port : Port selected.
REMARK The SioCTS function is used to detect if CTS (Clear To Send)
is set (1) or clear (0). Some Windows Win16 COMM drivers
cannot read the CTS bit correctly!
The CTS line is used by some error correcting modems to
implement hardware flow control. CTS is dropped by the modem
to signal the computer not to send data and is raised to
signal the computer to continue.
Refer to the User's Manual for a discussion of flow control.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
0 : CTS has not changed.
>0 : CTS has changed.
OTHER See SioFlow and SioRead.
+-------------+-----------------------------------------------------+
| SioDCD | Reads the Data Carrier Detect (DCD) modem status bit|
+-------------+-----------------------------------------------------+
SYNTAX int SioDCD(int Port)
// Port : Port selected.
REMARK The SioDCD function is used to read the Data Carrier Detect
(DCD) modem status bit. Also see SioStatus.
SioDCD is normally used after connecting to check that the
carrier has not been dropped.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
0 : DCD is clear.
>0 : DCD is set.
OTHER See SioRead.
WSC4C Reference Manual Page 5
+-------------+-----------------------------------------------------+
| SioDone | Terminates further serial processing. |
+-------------+-----------------------------------------------------+
SYNTAX int SioDone(int Port)
// Port : Port selected.
REMARK The SioDone function terminates further serial processing,
allowing other applications to use the port.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
OTHER See SioReset.
+-------------+-----------------------------------------------------+
| SioDSR | Reads the Data Set Ready (DSR) modem status bit. |
+-------------+-----------------------------------------------------+
SYNTAX int SioDSR(int Port)
// Port : Port selected.
REMARK The SioDSR function is used to detect if DSR (Data Set Ready)
is set (1) or clear (0). Some Windows Win16 COMM drivers
cannot read the DSR bit correctly!
Modems normally set DSR as soon as they are powered up.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
0 : DSR has not changed.
>0 : DSR has changed.
OTHER See SioRead.
WSC4C Reference Manual Page 6
+-------------+-----------------------------------------------------+
| SioDTR | Set, clear, or read Data Terminal Ready (DTR). |
+-------------+-----------------------------------------------------+
SYNTAX int SioDTR(int Port, int Cmd)
// Port : Port selected.
// Cmd : DTR command (see below).
REMARK The SioDTR function controls the Data Terminal Ready (DTR) bit
in the modem control register. DTR should always be set when
communicating with a modem. Commands (defined in WSC.H):
SET_LINE : 'S' to set DTR (ON)
CLEAR_LINE : 'C' to clear DTR (OFF)
READ_LINE : 'R' to read DTR
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
WSC_RANGE : Not one of 'S', 'C', or 'R'.
0 : DTR is OFF (READ_LINE Command).
>0 : DTR is ON (READ_LINE Command).
OTHER See SioRead.
+------------+------------------------------------------------------+
| SioFlow | Sets hardware (RTS/CTS) flow control. |
+------------+------------------------------------------------------+
SYNTAX int SioFlow(int Port, int Cmd)
// Port : Port selected.
// Cmd : Class of flow control (see below).
REMARK The SioFlow function is used to enable or disable hardware
flow control. Hardware flow control uses RTS and CTS to
control data flow between the modem and the computer. To
enable flow control, call SioFlow with Cmd set to:
Cmd Flow Control
'H' Hardware (RTS/CTS) flow control.
'S' Software (XON/XOFF) flow control.
'N' No flow control [default].
In order for hardware flow control to work correctly, your
modem must also be configured to work with hardware flow
control, and your computer to modem cable must have RTS and
CTS wired straight through. If you enable hardware flow
control, do not modify the RTS line (by calling SioRTS). Flow
control is disabled after resetting a port.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
WSC_RANGE : Cannot recognize Cmd.
>0 : Flow control enabled.
0 : Flow control disabled.
OTHER See SioPutc
WSC4C Reference Manual Page 7
+------------+------------------------------------------------------+
| SioGetc | Reads the next character from the serial line. |
+------------+------------------------------------------------------+
SYNTAX int SioGetc(int Port)
// Port : Port selected.
REMARK The SioGetc function reads a byte from the selected serial
port. WSC_NO_DATA (-100) is returned if no byte is available.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
WSC_NO_DATA : If timed out (no data available).
>= 0 : Character read.
OTHER See SioUnGetc and SioGets.
+------------+------------------------------------------------------+
| SioGets | Reads the next byte buffer from the serial line. |
+------------+------------------------------------------------------+
SYNTAX int SioGetc(int Port, char *String, int Cnt)
// Port : Port selected
// Buffer : Receive buffer
// Cnt : Number bytes wanted
REMARK The SioGets function reads the smaller of the number of bytes
wanted (Cnt) and the number of bytes in the receive buffer. A
zero is return if no bytes are read.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
>= 0 : Number of characters actually read.
OTHER See SioUnGetc and SioPutc.
WSC4C Reference Manual Page 8
+-------------+-----------------------------------------------------+
| SioInfo | Returns WSC4C library information. |
+-------------+-----------------------------------------------------+
SYNTAX int SioInfo(int Cmd)
// Cmd : Command (See below)
REMARK The SioInfo function returns an integer code corresponding to
the Cmd as follows.
Command SioInfo returns
'V' Library version number.
'?' Seconds until executable expires.
The '?' command can be used in the shareware version to find
the number of seconds left before the executable expires,
after which the application must be restarted. This function
only has meaning in the SHAREWARE version of WSC.
RETURN See remarks above.
-1 : Cannot recognize command 'Cmd'.
+-------------+-----------------------------------------------------+
| SioParms | Sets parity, stop bits, and word length. |
+-------------+-----------------------------------------------------+
SYNTAX int SioParms(int Port, int Parity,
int StopBits, int DataBits)
// Port : Port selected.
// Parity : Parity code [0,1,2,3,4].
// StopBits : Stop bits code [0,1].
// DataBits : Word length code [0,1,2,3].
REMARK The SioParms function sets the parity, stop bits, and word
length. If the default parity (none), stop bits (1), or word
length (8) is not acceptable, then they can be changed by
calling SioParms. SioParms can be called either before or
after calling SioReset. See file WSC.H.
Use the constant values defined in WSC.H to minimize the
chance of passing an incorrect parameter value.
Parity : NoParity, OddParity, EvenParity, MarkParity,
SpaceParity.
StopBits : OneStopBit, TwoStopBits.
DataBits : WordLength7, WorldLength8.
RETURN IE_BADID : No such port.
IE_BYTESIZE : Word length not supported.
WSC_RANGE : Parameter out of range.
OTHER See SioReset.
WSC4C Reference Manual Page 9
+-------------+-----------------------------------------------------+
| SioPutc | Transmit a character over a serial line. |
+-------------+-----------------------------------------------------+
SYNTAX int SioPutc(int Port, int Ch)
// Port : Port selected.
// Ch : Character to send.
REMARK The SioPutc function copies the character to the transmit
queue for subsequent transmission.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
0 : No error.
OTHER See SioGetc and SioFlow.
+-------------+-----------------------------------------------------+
| SioPuts | Transmits a byte buffer over a serial line. |
+-------------+-----------------------------------------------------+
SYNTAX int SioPutc(int Port, char *String, int Cnt)
// Port : Port selected.
// Buffer : String of bytes to transmit.
REMARK The SioPuts function copies 'String' to the transmit queue for
subsequent transmission.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
>= 0 : The number of bytes actually transmitted.
OTHER See SioGetc and SioFlow.
WSC4C Reference Manual Page 10
+-------------+-----------------------------------------------------+
| SioRead | Reads any UART register. |
+-------------+-----------------------------------------------------+
SYNTAX int SioRead(int Port, int Reg)
// Port : Port selected.
// Reg : UART register (0 to 7).
REMARK The SioRead function reads any of the 7 I/O ports directly,
by-passing the Windows API. Note that the line status and the
modem status registers can be read by:
#define SioLine(Port) SioRead(Port,5)
#define SioModem(Port) SioRead(Port,6)
Note that all modem and/or line status bits can also be read
using SioDTR, SioRTS, SioDCD, SioRI, SioDSR, and SioCTS. Refer
to the User's Manual for a description of the UART registers.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
>0 : Contents of selected UART register.
OTHER See SioStatus.
+-------------+-----------------------------------------------------+
| SioReset | Initialize a serial port for processing. |
+-------------+-----------------------------------------------------+
SYNTAX int SioReset(int Port, int RxQueSize, int TxQueSize)
// Port : Port selected.
// RxQueSize : Receive queue size.
// TxQueSize : Transmit queue size.
REMARK The SioReset function initializes the selected serial port.
SioReset should be called before making any other calls to
WSC4C. SioReset uses the parity, stop bits, and word length
value previously set if SioParms was called, otherwise the
default values (see SioParms) are used.
RETURN IE_BADID : No such port.
IE_OPEN : Already open.
IE_MEMORY : Cannot allocate memory.
IE_HARDWARE : Hardware error.
OTHER See SioBaud, SioParms, and SioDone.
WSC4C Reference Manual Page 11
+-------------+-----------------------------------------------------+
| SioRI | Reads the Ring Indicator (RI) modem status bit. |
+-------------+-----------------------------------------------------+
SYNTAX int SioRI(int Port)
// Port : Port selected.
REMARK The SioRI function is used to read the Ring Indicator (RI)
modem status bit.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
0 : RI is clear.
>0 : RI is set (RING has occurred).
OTHER See SioRead.
+-------------+-----------------------------------------------------+
| SioRTS | Sets, clears, or reads the Request to Send (RTS). |
+-------------+-----------------------------------------------------+
SYNTAX int SioRTS(int Port, int Cmd)
// Port : Port selected.
// Cmd : RTS command (SET, CLEAR, or READ)
REMARK The SioRTS function controls the Request to Send (RTS bit in
the modem control register.
The RTS line is used by some error correcting modems to
implement hardware flow control. RTS is dropped by the
computer to signal the modem not to send data, and is raised
to signal the modem to continue. RTS should be set when
communicating with a modem unless Flow Control is being used.
Refer to the User's Manual for a discussion of flow control.
Commands (defined in WSC.H) are:
SET_LINE 'S' : set RTS (ON)
CLEAR_LINE 'C' : clear RTS (OFF)
READ_LINE 'R' : read RTS
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
WSC_RANGE : Command is not one of 'S', 'C', or 'R'.
0 : RTS is OFF ('R' command).
>0 : RTS is ON ('R' command).
OTHER See SioFlow and SioDTR.
WSC4C Reference Manual Page 12
+------------+------------------------------------------------------+
| SioRxClear | Clears the receive buffer. |
+------------+------------------------------------------------------+
SYNTAX int SioRxClear(int Port)
// Port : Port selected.
REMARK The SioRxClear function will delete any characters in the
receive buffer for the specified port. After execution, the
receive buffer will be empty.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
OTHER See SioRxQue.
+-------------+-----------------------------------------------------+
| SioRxQue | Returns the number of bytes in the receive queue. |
+-------------+-----------------------------------------------------+
SYNTAX int SioRxQue(int Port)
// Port : Port selected.
REMARK The SioRxQue function will return the number of characters in
the receive queue at the time of the call.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
OTHER See SioRxFlush.
WSC4C Reference Manual Page 13
+------------+------------------------------------------------------+
| SioStatus | Returns the serial port status. |
+------------+------------------------------------------------------+
SYNTAX int SioStatus(int Port, int Mask)
// Port : Port selected.
// Mask : Error mask.
REMARK The SioStatus function returns the serial port error status
corresponding to the Mask argument.
WSC_RXOVER : The receive queue overflowed.
WSC_OVERRUN : An incoming byte was overwritten.
WSC_PARITY : A parity error was detected (incoming byte)
WSC_FRAME : A framing error was detected (incoming byte)
WSC_BREAK : A break signal was detected.
WSC_TXFULL : The transmit queue is full.
For example, to test for receive queue overflow:
if(SioStatus(Port, WSC_RXOVER)) printf("RX Overflow");
The numerical values of the mask constants are defined in
WSC.H.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
OTHER See SioRead.
+------------+------------------------------------------------------+
| SioTxClear | Clears the transmitter buffer. |
+------------+------------------------------------------------------+
SYNTAX int SioTxClear(int Port)
// Port : Port selected.
REMARK The SioTxClear function will delete any characters in the
transmit buffer for the specified port.
Once this function is called, any character in the transmit
buffer (put there by SioPutc) will be lost and therefore not
transmitted.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
OTHER See SioTxQue & SioTxFlush.
WSC4C Reference Manual Page 14
+------------+------------------------------------------------------+
| SioTxQue | Returns the number of bytes in the transmit queue. |
+------------+------------------------------------------------------+
SYNTAX int SioTxQue(int Port)
// Port : Port selected.
REMARK The SioTxQue function will return the number of characters in
the transmit queue at the time of the call.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
OTHER See SioTxFlush.
+------------+------------------------------------------------------+
| SioUnGetc | "Ungets" the last character read with SioGetc(). |
+------------+------------------------------------------------------+
SYNTAX int SioUnGetc(int Port, char Ch)
// Port : Port selected.
// Ch : Character to unget.
REMARK The SioUnGetc function returns ("pushes") the character back
into the serial input buffer. The character pushed will be
the next character returned by SioGetc. Only one character
can be pushed back. This function works just like the
"ungetc" function in the C language.
RETURN IE_NOPEN : Port not opened. Call SioReset first.
IE_BADID : No such port.
OTHER See SioReset.
WSC4C Reference Manual Page 15
WSC Error Codes
+---------------+---------------------------------------------+
| WSC_NO_DATA | No incoming serial data is available. |
| WSC_RANGE | A parameter is out of range. |
| WSC_ABORTED | The shareware version of WSC corrupted. |
| WSC_WIN32ERR | Win32 system error. |
| WSC_EXPIRED | The shareware version of WSC has expired. |
+---------------+---------------------------------------------+
| IE_BADID | No such port. |
| IE_OPEN | Port already opened. |
| IE_NOPEN | Port not opened. Call SioReset first. |
| IE_MEMORY | Cannot allocate memory for queues. |
| IE_DEFAULT | Error in default parameters. |
| IE_HARDWARE | Hardware not present. |
| IE_BYTESIZE | Unsupported byte size. |
| IE_BAUDRATE | Unsupported baud rate. |
+---------------+---------------------------------------------+
The WSC_EXPIRED error occurs when in the shareware DLL only. It
limits the execution of an WSC DLL to 20 minutes of execution. The
application must be restarted to continue serial processing.
The WSC_ABORTED error occurs in the shareware version only if there
is a problem displaying the shareware screen.
The WSC_WIN32ERR error code is returned only for Win32 system errors.
Call SioError to format the textual error message.
WSC4C Reference Manual Page 16
+-----------+-------------------------------------------------------+
| mioBreak | Aborts the Modem I/O state driver. |
+-----------+-------------------------------------------------------+
SYNTAX int mioBreak(int Port)
// Port : Port selected.
REMARK Forces the MIO driver to the IDLE state, abandoning any work
in progress (if any). Used to abort mioSendTo, mioQuiet, and
mioWaitFor functions.
RETURN MIO_IDLE.
+------------+------------------------------------------------------+
| mioDriver | Modem I/O state driver. |
+------------+------------------------------------------------------+
SYNTAX int mioDriver(int Port)
// Port : Port selected.
REMARK Executes the next state of any previously started MIO function
such as mioSendTo, mioWaitFor, and mioQuiet. Returns MIO_IDLE
(defined in MIO.H) if ready not running, MIO_RUNNING if
running, and anything else is a character from the modem that
can be displayed if wanted.
RETURN MIO_IDLE : if the driver is ready for the next mioSendTo,
mioWaitFor, or mioQuiet.
MIO_RUNNING : if the driver is not idle.
<else> : if the driver is not idle, and the returned
character was received from the modem.
WSC4C Reference Manual Page 17
+-----------+-------------------------------------------------------+
| mioQuiet | Waits for Modem I/O state driver. |
+-----------+-------------------------------------------------------+
SYNTAX int mioQuiet(int Port, long Wait)
// Port : Port selected.
// Wait : Wait in milliseconds.
REMARK The mioQuiet function waits for continuous quiet [no incoming
serial data] of 'Wait' milliseconds before returning. Any
incoming character while mioQuiet is running is lost.
RETURN TRUE.
+------------+------------------------------------------------------+
| mioResult | Returns result of last mioWaitFor. |
+------------+------------------------------------------------------+
SYNTAX int mioResult(int Port)
// Port : Port selected.
REMARK The mioResult function returns the result of the last
mioWaitFor function. This function should not be called until
the driver returns MIO_IDLE. See the remarks section of the
mioWaitFor function for an example.
RETURN 0 : False (last WaitFor not matched)
!0 : '0' if first substring matched, '1' if second substring
matched, etc.
OTHER See mioWaitFor.
WSC4C Reference Manual Page 18
+-----------+-------------------------------------------------------+
| mioSendTo | Sends string to modem. |
+-----------+-------------------------------------------------------+
SYNTAX int mioSendTo(int Port, long Pace, LPSTR String)
// Port : Port selected.
// Pace : The inter-character delay in milliseconds.
// String : The string to send.
REMARK The mioSendTo function sends the characters in the string
'Text' to serial output. There is a delay of 'Pace'
milliseconds between characters.
RETURN TRUE.
+-------------+-----------------------------------------------------+
| mioWaitFor | Waits for continuous quiet. |
+-------------+-----------------------------------------------------+
SYNTAX int mioWaitFor(int Port, long Wait, LPSTR String)
// Port : Port selected.
// Wait : Total time to wait for response (milliseconds).
// String : The expected response string.
REMARK The mioWaitFor function waits for characters from serial
input that match the string 'Text'. A total of 'Wait'
milliseconds are allowed before timing out and returning FALSE
(0). The string comparison is NOT case sensitive.
For example, to wait up to one minute for "CONNECT", "NO
CARRIER", or "BUSY" from the modem after dialing a number.
Code = mioWaitFor(Port,60000,"CONNECT|NO CARRIER|BUSY")
The function mioDriver() must be called until MIO_IDLE is
returned. Then mioResult() is called to get the result of the
mioWaitFor. A value of 0 indicates that neither "CONNECT",
"BUSY", nor "NO CARRIER" was received. A non-zero value
indicates that one of the three sub-strings was received. A
'0' is returned if "CONNECT" was seen, '1' is returned if "NO
CARRIER" was seen, and '2' is returned if "BUSY" was seen.
RETURN TRUE.
OTHER See mioResult.
WSC4C Reference Manual Page 19
+---------+---------------------------------------------------------+
| xyAbort | Aborts the XYDRIVER state driver. |
+---------+---------------------------------------------------------+
SYNTAX int xyAbort(int Port);
// Port : Port selected.
REMARK The xyAbort function forces the driver to IDLE, terminating
any file transfer which may be in progress.
RETURN XY_NO_ERROR (0).
+-----------+-------------------------------------------------------+
| xyAcquire | Prepares the state driver for operation. |
+-----------+-------------------------------------------------------+
SYNTAX int xyAcquire(int Port);
// Port : Port selected.
REMARK The xyAcquire function initializes the driver for subsequent
use. This should be the first driver function called.
RETURN =0 : No error (XY_NO_ERROR).
<0 : XYDRIVER error. See "XYDRIVER Error Codes".
OTHER See xyRelease.
WSC4C Reference Manual Page 20
+----------+--------------------------------------------------------+
| xyDebug | Set the driver debug level. |
+----------+--------------------------------------------------------+
SYNTAX int xyDebug(int DebugLevel);
// DebugLevel : Debug level value.
REMARK The xyDebug functions sets the driver debug level as follows:
DebugLevel : Meaning
0 Only error messages are generated [default].
1 Minimal debug messages are generated.
2 Maximal debug messages are generated.
Debug messages are retrieved using the xyGetMessage function.
RETURN New debug level [0,1,2]
+----------+--------------------------------------------------------+
| xyDriver | XMODEM / YMODEM state driver. |
+----------+--------------------------------------------------------+
SYNTAX int xyDriver(int Port);
// Port : Port selected.
RETURN XY_IDLE : A transfer is not underway.
XY_RUNNING : A transfer is underway.
REMARK The xyDriver function drives the state engine. It is normally
called within a timer loop. Note that xyDriver never returns
an error code.
xyDriver can be called as often as wanted whether or not a
file transfer was initiated.
OTHER See xyStartTx and xyStartRx.
WSC4C Reference Manual Page 21
+--------------+----------------------------------------------------+
| xyGetMessage | Get next XYDRIVER message. |
+--------------+----------------------------------------------------+
SYNTAX int xyGetMessage(LPSTR Buffer, int Size);
// Buffer : Message buffer.
// Size : Size of message buffer.
REMARK The xyGetMessage function retrieves the next message from the
driver message queue. Refer to the TERM.C example program for
an example of using xyGetMessage.
RETURN TRUE : A message was copied into Buffer.
FALSE : No messages are available.
OTHER See xyDebug.
+----------------+--------------------------------------------------+
| xyGetParameter | Retrieves driver parameter. |
+----------------+--------------------------------------------------+
SYNTAX long xyGetParameter(int Port, int Parameter);
// Port : Port Selected.
// Parameter : Parameter to return.
REMARK The driver parameter corresponding to the following table is
returned.
Parameter : Description
XY_GET_ERROR_CODE : Driver error code (see XYDRIVER.H)
XY_GET_ERROR_STATE : Error state (if in error).
XY_GET_PACKET : Current packet number.
XY_GET_STATE : Current state (see XYDRIVER.C).
XY_GET_FILE_SIZE : File size.
XY_GET_NBR_NAKS : Number of packets ACKed.
XY_GET_LAST_GET : Last incoming (serial) character.
XY_GET_LAST_PUT : Last outgoing (serial) character.
XY_GET_GET_COUNT : Number of incoming characters (bytes).
XY_GET_PUT_COUNT : Number of outgoing characters (bytes).
XY_GET_DRIVER_COUNT : Number times xyDriver() was called.
-1 : Cannot recognize parameter.
The xyGetParameter function can be used to check the state of
the driver. For example:
(1) xyGetParameter(Port,XY_GET_STATE) returns XY_IDLE if idle.
(2) xyGetParameter(Port,XY_GET_ERROR_CODE) returns the driver
error code if an error has occurred or XY_NO_ERROR (0)
otherwise.
RETURN See above.
WSC4C Reference Manual Page 22
+-----------+-------------------------------------------------------+
| xyRelease | Releases driver port. |
+-----------+-------------------------------------------------------+
SYNTAX int xyRelease(int Port).
// Port : Port selected.
REMARK The xyRelease function releases a port that was previously
acquired with xyAcquire. This function should be called before
calling the WSC function SioDone.
RETURN 0 : No error (XY_NO_ERROR).
<0 : XYDRIVER error. See "XYDRIVER Error Codes".
OTHER See xyAcquire.
+-----------+-------------------------------------------------------+
| xyStartRx | Start XMODEM or YMODEM receive. |
+-----------+-------------------------------------------------------+
SYNTAX int xyStartRx(int Port, LPSTR Filename, char NCGchar,
int Batch)
// Port : Port to use
// Filename : File to receive (XMODEM only)
// NCGchar : NAK, 'C', or 'G'
// Batch : YMODEM flag (T/F)
REMARK The xyStartRx starts the XMODEM or YMODEM file receive. Once
started, calls to xyDriver are made to execute the next state
(or states). The xyStartTx function returns immediately.
The protocols supported and their parameters are as follows:
Protocol : NCGchar BatchFlag : Comments
XMODEM : NAK FALSE Standard XMODEM
XMODEM/CRC : 'C' FALSE
XMODEM/1K : 'C' FALSE
YMODEM : 'C' TRUE Standard YMODEM
The xyStartRx function is used to receive a file using XMODEM
or YMODEM.
RETURN =0 : No error (XY_NO_ERROR).
<0 : Driver error. See "XYDRIVER Error Codes" a list of errors.
OTHER See xyStartTx and xyDriver.
WSC4C Reference Manual Page 23
+-----------+-------------------------------------------------------+
| xyStartTx | Start XMODEM or YMODEM transmit. |
+-----------+-------------------------------------------------------+
SYNTAX int xyStartTx(int Port,LPSTR Filename,int OneK,int Batch)
// Port : Port to use
// Filename : File to send.
// OneK : Want 1K blocks (T/F).
// Batch : YMODEM flag (T/F)
REMARK The xyStartTx starts the XMODEM or YMODEM file send. Once
started, calls to xyDriver are made to execute the next state
(or states). The xyStartTx function returns immediately.
The protocols supported and their parameters are as follows:
Protocol : OneKflag BatchFlag : Comments
XMODEM : FALSE FALSE Standard XMODEM
XMODEM/CRC : FALSE FALSE
XMODEM/1K : TRUE FALSE
YMODEM : TRUE TRUE Standard YMODEM
RETURN =0 : No error (XY_NO_ERROR).
<0 : Driver error. See XYDRIVER.H for a list of errors.
OTHER See xyStartRx and xyDriver.
XYDRIVER Error Codes
Error codes are always negative, except for "no error". Most of these
error conditions rarely occur. Also note that XYDRIVER functions can
return WSC errors. An error message is queued when an error occurs
which can be retrieved with xyGetMessage.
The numeric values for error codes can be found in XYDRIVER.H.
+--------------------------+----------------------------------------+
| XY_NO_ERROR | No error. (0) |
| XY_UNKNOWN_ERROR | Unknown error. |
| XY_ALREADY_ACTIVE_ERROR | Port already acquired. |
| XY_CANNOT_OPEN_ERROR | Cannot open specified file. |
| XY_EMPTY_FILE_ERROR | Specified file is empty. |
| XY_NO_STARTUP_CHAR_ERROR | Must specify NAK, 'C', or 'G'. |
| XY_NOT_NCG_ERROR | Expected NAK, 'C', or 'G'. |
| XY_DISK_READ_ERROR | Error reading disk. |
| XY_NO_EOT_ACK_ERROR | EOT was not ACKed. |
| XY_INTERNAL_ERROR | Internal error! |
| XY_CANCELLED_ERROR | Other side canceled. |
| XY_OUT_OF_SYNC_ERROR | Protocol has lost synchronization. |
| XY_RETRIES_ERROR | Packet retry limit was exceeded. |
| XY_BAD_PACKET_NBR_ERROR | Incorrect packet number. |
| XY_TIMED_OUT_ERROR | Timed out waiting for other side. |
| XY_NO_SUCH_FILE_ERROR | No such file. |
| XY_NOT_ACTIVE_ERROR | Port not acquired by xyAcquire. |
| XY_PORT_RANGE_ERROR | Port number out of range. |
+--------------------------+----------------------------------------+
WSC4C Reference Manual Page 24